package code06_数组;

import java.util.Arrays;

public class Test09_Arrays工具类 {
	public static void main(String[] args) {
		int[] nums = { 14, 2, 54, 24, 120, 34, 6 };
		
		/*
		 * toString()　将数组转换为字符串
		 */
		System.out.println(Arrays.toString(nums));
		
		/*
		 * sort()　排序
		 */
		Arrays.sort(nums); // 默认是升序
		System.out.println(Arrays.toString(nums));
		
		/*
		 * fill() 填充/初始化
		 */
		// Arrays.fill(nums, 0);
		// System.out.println(Arrays.toString(nums));
		
		/*
		 * copyOf() 复制数组
		 */
		int[] nums2 = Arrays.copyOf(nums, 5); // 拷贝前5个元素，返回一个新数组
		System.out.println(Arrays.toString(nums2));
		
		/*
		 * copyOfRange() 复制数组
		 */ 
		int[] nums3 = Arrays.copyOfRange(nums, 2, 4); // 拷贝索引为[2,4)的元素
		System.out.println(Arrays.toString(nums3));
		
		
		
	}
}
